@extends('admin/layout.app')

@section('title', '资源编辑')

@section('content')
    @if (count($errors) > 0)
        <div class="col-lg-9">
            <div class="alert alert-danger">
                <ul>
                    @if(is_object($errors))
                        @foreach($errors->all() as $error)
                            <li>{{$error}}</li>
                        @endforeach
                    @else
                        <li>{{$errors}}</li>
                    @endif
                </ul>
            </div>
        </div>
    @endif
    <div class="col-lg-10">
        @if($tourist_info)
            <form class="form-horizontal" action="/admin/tourist/{{$tourist_info['id']}}" method="post">
                <input type="hidden" name="_method" value="put">
                {{csrf_field()}}
                <div class="form-group">
                    <label class="col-sm-2 control-label">ID</label>
                    <div class="col-sm-2">
                        <label class="control-label">{{$tourist_info['id']}}</label>
                    </div>
                    <label class="col-sm-2 control-label">来源</label>
                    <div class="col-sm-2">
                        <label class="control-label">{{$tourist_info['source_id']}}</label>
                    </div>
                </div>
                <div class="form-group">
                    <label for="input-name-1" class="col-sm-2 control-label">姓名</label>
                    <div class="col-sm-2">
                        <input type="text" name="name" class="form-control" id="input-name-1" placeholder="姓名"
                               value="{{$tourist_info['name']}}">
                    </div>
                    <label for="input-name-2" class="col-sm-2 control-label">手机号</label>
                    <div class="col-sm-2">
                        <input type="text" name="phone" class="form-control" id="input-name-2" placeholder="手机号"
                               value="{{$tourist_info['phone']}}">
                    </div>
                </div>
                <div class="form-group">
                    <label for="input-city-1" class="col-sm-2 control-label">城市</label>
                    <div class="col-sm-2">
                        <input type="text" name="city" class="form-control" id="input-city-1" placeholder="城市"
                               value="{{$tourist_info['city']}}">
                    </div>
                    <label for="input-city-2" class="col-sm-2 control-label">状态</label>
                    <div class="col-sm-2">
                        <select class="form-control" name="status">
                            <option value="1" {{$tourist_info['status'] == 1 ? 'selected' : ''}} >有效</option>
                            <option value="2" {{$tourist_info['status'] == 2 ? 'selected' : ''}}>关机</option>
                            <option value="3" {{$tourist_info['status'] == 3 ? 'selected' : ''}}>未接通</option>
                            <option value="4" {{$tourist_info['status'] == 4 ? 'selected' : ''}}>空号（停机）</option>
                            <option value="5" {{$tourist_info['status'] == 5 ? 'selected' : ''}}>拒接</option>
                            <option value="6" {{$tourist_info['status'] == 6 ? 'selected' : ''}}>中途挂断</option>
                            <option value="7" {{$tourist_info['status'] == 7 ? 'selected' : ''}}>中介</option>
                            <option value="8" {{$tourist_info['status'] == 8 ? 'selected' : ''}}>已购房</option>
                            <option value="0" {{$tourist_info['status'] == 9 ? 'selected' : ''}}>不买房（无效）</option>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label for="input-shop" class="col-sm-2 control-label">商圈</label>
                    <input type="hidden" name="business_area" value="{{$tourist_info['business_area']}}">
                    <input type="hidden" name="business_area_ids" value="{{$tourist_info['business_area_ids']}}">
                    <div class="col-sm-8">
                        <p>
                            @if($tourist_info['business_area'])
                                @foreach(explode(',',$tourist_info['business_area']) as $key => $item)
                                    <button class="btn btn-info">{{$item}} <i class="fa fa-remove"
                                                                              aria-hidden="true"></i></button>
                                @endforeach
                            @endif
                        </p>
                        <input type="text" class="form-control" placeholder="添加商圈">
                    </div>
                </div>
                <div class="form-group">
                    <label for="input-d" class="col-sm-2 control-label">小区</label>
                    <input type="hidden" name="district" value="{{$tourist_info['district']}}">
                    <input type="hidden" name="district_ids" value="{{$tourist_info['district_ids']}}">
                    <div class="col-sm-8">
                        <p>
                            @if($tourist_info['district'])
                                @foreach(explode(',',$tourist_info['district']) as $key => $item)
                                    <button class="btn btn-info">{{$item}} <i class="fa fa-remove"
                                                                              aria-hidden="true"></i></button>
                                @endforeach
                            @endif
                        </p>
                        <input type="text" class="form-control" placeholder="添加小区">
                    </div>
                </div>
                <div class="form-group">
                    <label for="input-room" class="col-sm-2 control-label">居室</label>
                    <div class="col-sm-2">
                        <input type="text" name="house_room" class="form-control" id="input-room" placeholder="居室"
                               value="{{$tourist_info['house_room']}}">
                    </div>
                    <label for="input-price" class="col-sm-2 control-label">价格</label>
                    <div class="col-sm-2">
                        <input type="text" name="price" class="form-control" id="input-price" placeholder="价格"
                               value="{{$tourist_info['price']}}">
                    </div>
                </div>
                <div class="form-group">
                    <label for="input-area" class="col-sm-2 control-label">面积</label>
                    <div class="col-sm-2">
                        <input type="text" name="area" class="form-control" id="input-area" placeholder="面积"
                               value="{{$tourist_info['area']}}">
                    </div>
                    <label for="input-area" class="col-sm-2 control-label">购买意向</label>
                    <div class="col-sm-2">
                        <select class="form-control" name="purpose">
                            <option value="A" {{$tourist_info['purpose'] == 'A' ? 'selected' : ''}} >需求明确,购房条件清晰</option>
                            <option value="B" {{$tourist_info['purpose'] == 'B' ? 'selected' : ''}}>需求范围广,购房条件清晰但不优质</option>
                            <option value="C" {{$tourist_info['purpose'] == 'C' ? 'selected' : ''}}>无明确购房范围,需求或不清晰</option>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label for="input-use" class="col-sm-2 control-label">购买用途</label>
                    <div class="col-sm-2">
                        <select class="form-control" name="use">
                            <option value="0" {{$tourist_info['use'] == 0 ? 'selected' : ''}}>未知</option>
                            <option value="1" {{$tourist_info['use'] == 1 ? 'selected' : ''}}>首套自住</option>
                            <option value="2" {{$tourist_info['use'] == 2 ? 'selected' : ''}}>投资</option>
                            <option value="3" {{$tourist_info['use'] == 3 ? 'selected' : ''}}>换房</option>
                            <option value="4" {{$tourist_info['use'] == 4 ? 'selected' : ''}}>婚房</option>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label for="input-use" class="col-sm-2 control-label">备注</label>
                    <div class="col-sm-8">
                        <textarea class="form-control" name="remark">{{$tourist_info['remark']}}</textarea>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-offset-3 col-sm-10">
                        <button type="submit" class="btn btn-default">保存</button>
                    </div>
                </div>
            </form>
        @else
            <p>资源信息不存在，请重新访问</p>
        @endif
    </div>
@endsection
